<template>
  <el-dialog :visible.sync="dialogVisible" :before-close="cancel" width="40%" :close-on-press-escape=false
             :close-on-click-modal=false>
    <template slot="title">
      <span >黑名单基础设置</span>
    </template>
    <el-form
     ref="refForm"
      :rules="refRule"
      :disabled="loading"
      :model="form" class="demo-form-inline">
      <el-form-item label="群组名称:" prop="levelName" >
        <el-col :span="16">
          <el-input placeholder="请输入群组名称" v-model.trim="form.levelName" maxlength="22"></el-input>
        </el-col>
      </el-form-item>
      <el-form-item label="备注:" prop="remark">
        <el-col :span="17">
          <el-input placeholder="请输入备注" type="textarea" v-model.trim="form.remark" maxlength="22"></el-input>
        </el-col>
      </el-form-item>
      <div style="text-align:right">
        <el-button class="filter-item"
                   @click="cancel">取消
        </el-button>
        <el-button class="filter-item" type="primary"
                   @click="toSave">确认
        </el-button>
      </div>
    </el-form>
  </el-dialog>
</template>
<script>
import { form, grid, factory } from '@/build';
import { blackListLevalUpdate } from '@/services/api/risk';

export default {
  name: 'basic-settings-dialog',
  mixins: [form, grid, factory],
  props: {
    dialogVisible: {
      required: true,
    },
    rowData: {
      required: true,
    },
  },
  data() {
    return {
      inValidateUsers: [],
      form: {
        levelId: undefined,
        levelName: undefined,
        remark: undefined,
      },
      refRule: {
        levelName: [
          { required: true, message: '名称不能为空' },
        ],
        remark: [
          { required: true, message: '备注不能为空' },
        ],
      },
      amountError: '',
    };
  },

  methods: {
    cancel() {
      this.$emit('cancel');
    },
    toSave() {
      this.$refs.refForm.validate((valid) => {
        if (valid) {
          this.doSave({ action: 'updateLeval' });
        }

      });
    },
  },
  mounted() {
    this.form.levelId = this.rowData.id;
    this.form.levelName = this.rowData.levelName;
    this.form.remark = this.rowData.remark;
    this.bindSave(blackListLevalUpdate, 'updateLeval', 'form', {// 修改等级名称
      afterSuccess: ([result]) => {
        if (!result) return;
        this.$emit('cancel');
        this.$parent.getAll();
      },
    });
  },

};
</script>

<style lang="scss" scoped>
  // /deep/ .el-input,.el-textarea{width:auto !important}
  /deep/ .el-table{width:71%}
  /deep/ .relative{position: relative;top:10px}
  /deep/ .table-box{position:relative;top:-7px}
</style>
